export class EventEmitter {
  events: Map<string, any[]>;
  constructor() {
    this.events = new Map();
  }

  on(event, callback) {
    const handlers = this.events.get(event) || [];
    handlers.push(callback);
    this.events.set(event, handlers);
  }

  emit(event, ...args) {
    const handlers = this.events.get(event);
    if (handlers) {
      handlers.forEach((handler) => handler(...args));
    }
  }
  clear() {
    this.events = new Map();
  }
}

export default new EventEmitter();
